<template>
  <div>
    <component :is="one"></component>

    <div id="container" >
      <div id="content2">
        <table width="100%" height="41"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="15" align="left" valign="top">&nbsp;</td>
            <td height="15" align="left" valign="top" class="12"><table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td height="20" align="center"><div class="right_proaducts">
                  <div align="left">我的位置&gt;&gt;科技项目申报&gt;单位信息 </div>
                </div>
                  <!--              <form action="s.html" method="post" id="form">-->
<!--                  <DIV class=padding>
                    <DIV id=middlebody>-->
                      <table cellspacing="0" cellpadding="0" width="100%" border="0">
                        <tbody>
                        <tr>
                          <td><div align="left">|&nbsp;&nbsp;欢迎,admin&nbsp;&nbsp;|&nbsp;&nbsp;
                            <a  class="table_t"  href="#/">注销      </a>&nbsp;&nbsp;|&nbsp;&nbsp;
                            <a href="javascript:history.go(-1)">后退</a>&nbsp;&nbsp;|</div></td>
                            <td>
                              <div align="center"><a
                                      href="#/admin/showusers">登录用户管理</a>
                              </div>
                          </td>
                          <td>
                              <div align="center"><a
                                      href="#/admin/showexperts">专家信息管理</a>
                              </div>
                          </td>
                          <td height="50">
                              <div align="center"><a
                                      href="#/admin/showunits">单位信息管理</a>
                              </div>
                          </td>
                          <td>
                              <div align="center"><a
                                      href="#/admin/showprojectCategorys">项目管理</a>
                              </div>
                          </td>
                        </tr>
                        </tbody>
                      </table>
                      <table id="app" width="60%" border="0" cellpadding="0" cellspacing="1">
                        <tbody>
                        <tr> </tr>
                        <tr>
                          <td height="20" align="middle" bgcolor="#f3f3f3">单位名称</td>
                          <td height="20" bgcolor="#f3f3f3"><div align="left">
                            <input id="unitname" v-model="unit.unitname" />
                          </div></td>
                        </tr>
                        <tr>
                          <td height="20" align="middle" bgcolor="#f3f3f3">单位地址</td>
                          <td height="20" bgcolor="#f3f3f3"><div align="left">
                            <input id="address" v-model="unit.address" />
                          </div></td>
                        </tr>
                        <tr>
                          <td height="20" align="middle" bgcolor="#f3f3f3">单位法人</td>
                          <td height="20" bgcolor="#f3f3f3"><div align="left">
                            <input id="corporation" v-model="unit.corporation" />
                          </div></td>
                        </tr>
                        <tr>
                          <td height="20" align="middle" bgcolor="#f3f3f3">注册资金</td>
                          <td height="20" bgcolor="#f3f3f3"><div align="left">
                            <input id="investment" v-model="unit.investment" />
                          </div></td>
                        </tr>
                        <tr>
                          <td height="20" align="middle" bgcolor="#f3f3f3">单位性质</td>
                          <td height="20" bgcolor="#f3f3f3"><div align="left">
                            <input id="type" v-model="unit.type" />
                          </div></td>
                        </tr>
                        <tr>
                          <td height="20" align="middle" bgcolor="#f3f3f3">单位电话</td>
                          <td height="20" bgcolor="#f3f3f3"><div align="left">
                            <input id="tel" v-model="unit.tel" />
                          </div></td>
                        </tr>
                        <tr>
                          <td height="20" align="middle" bgcolor="#f3f3f3">单位邮箱</td>
                          <td height="20" bgcolor="#f3f3f3"><div align="left">
                            <input id="email" v-model="unit.email" />
                          </div></td>
                        </tr>
                        <tr>
                          <td height="20" align="middle" bgcolor="#f3f3f3">单位传真</td>
                          <td height="20" bgcolor="#f3f3f3"><div align="left">
                            <input id="fax" v-model="unit.fax" />
                          </div></td>
                        </tr>
                        <tr>
                          <td height="20" align="middle" bgcolor="#f3f3f3">单位邮编</td>
                          <td height="20" bgcolor="#f3f3f3"><div align="left">
                            <input id="zipcode" v-model="unit.zipcode" />
                          </div></td>
                        </tr>
                        <tr>
                          <td align="middle" bgcolor="#f3f3f3">单位简介</td>
                          <td bgcolor="#f3f3f3"><div align="left">
                            <textarea id="textarea" v-model="unit.introduction" rows="5" cols="40"> </textarea>
                          </div></td>
                        </tr>
                        <tr>
                          <td height="30" colspan="2" align="middle" bgcolor="#f3f3f3">
                            <!--                        <input id="submit3" type="submit" value="修改" name="submit7" />-->
                            <button @click="updateUnit()">修改</button>
                            <input id="button23" type="reset" value="取消" name="button23" />                      </td>
                        </tr>
                        </tbody>
                      </table>
                      <div></div>
                      <!--              </form>-->
                </td>
              </tr>
            </table>
              <br/>
              <div class="table_wz"></div></td>
          </tr>
        </table>
      </div>
    </div>

    <component :is="two"></component>
  </div>
</template>
<script>
    import four from '../../util/four';
    import aaa from '@/components/header.vue'
    import bbb from '@/components/footer.vue'
    const options = {
        data() {
            return {
              one: 'aaa',
                two: 'bbb',
                unit: {},
            }
        },
        components:{
            aaa,bbb
        },
        mounted() {
            this.getUnit();
        },
        methods: {
            getUnit() {
                let parse = JSON.parse(sessionStorage.getItem("unit"));
                this.unit = parse;
            },
            updateUnit() {
                four.put("/units", this.unit).then((res) => {
                    if (res.data.code == 20031) {
                        this.$message.success("修改成功！");
                    }
                    if (res.data.code == 20030) {
                        this.$message.success("修改失败！");
                    }
                }).finally(() => {
                   this.$router.push('/admin/showunits');
                })
            },
        }
    }
    export default options;
</script>